package com.shxy.dao.insurance;

import com.shxy.entity.insurance.Customer;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 客户数据访问接口
 */
@Repository
public interface CustomerDao extends JpaRepository<Customer, Integer> {
    /**
     * 获取所以客户信息
     * @return
     */
    List<Customer> findAllByIsActive(Boolean isActive);

    /**
     * 查询公司信息
     * @return
     */
    @Query(nativeQuery = true, value = "SELECT DISTINCT company FROM t_customer")
    List<String> getCompanies();

    /**
     * 根据编号查询用户信息
     * @param id
     * @return
     */
    Customer findById(int id);
}
